package cn.my.framework.example;

import cn.my.framework.common.entity.Menu;
import com.alibaba.druid.support.json.JSONUtils;

import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

/**
 * Created by zhangl_lc on 2017/8/4.
 */
public class TestData {

    public static Map<String,String> myMenus = new LinkedHashMap<String,String>(){{
        put("我的分页","/page/example_my_page");
        put("我的编辑器","/page/example_my_edit");
        put("我的ECharts","/page/example_my_echarts");
        put("我的Ueditor","/page/example_my_ueditor");
        put("我的MdEditor","/page/example_my_mdeditor");
        put("Wang Editor","/page/example_my_wangeditor");
        put("CK Editor","/page/example_my_ckeditor");
        put("我的Tree","/page/example_my_tree");
        put("权限测试","/page/example_my_perm");
        put("模板测试","/page/example_my_template");
        put("我的Modeler","/activiti/modeler.html?modelId=7501");
        put("SetCookie","/page/example_my_cookie");
        put("Redirect","/example/redirect");
    }};

    public static Map<String,String> layMenus = new LinkedHashMap<String,String>(){{
        put("表格分页","/page/example_layui_page");
        put("按钮样式","/page/example_layui_btn");
        put("弹窗","/page/example_layui_layer");
        put("面板","/page/example_layui_panel");
        put("H2Console","/h2console");
    }};

    public static List<Menu> menuData(){
        List<Menu> menus = new LinkedList<>();
        String id = "menu1";
        Menu menu = new Menu(id,"text.menu.myexample",null);
        menus.add(menu);
        LinkedList<Menu> children = new LinkedList<>();
        menu.setChildren(children);
        int i = 0;
        for(String key : myMenus.keySet()){
            children.add(new Menu(id+""+(++i),key,myMenus.get(key)));
        }

        id = "menu2";
        menu = new Menu(id,"text.menu.layexample",null);
        menus.add(menu);
        children = new LinkedList<>();
        menu.setChildren(children);
        i = 0;
        for(String key : layMenus.keySet()){
            children.add(new Menu(id+""+(++i),key,layMenus.get(key)));
        }
        return menus;
    }


    public static String menuDataJson(){
       return JSONUtils.toJSONString(menuData());
    }

    public static void main(String[] args){

    }
}
